package org.example.demo.service;

import org.example.demo.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName: Fsk App
 * @Copyright: com.fsk
 * @Version: 1.0.0
 * @Author: chenming2
 * @UpdateTime: 2/28/2022
 * @Describe: XXXXXXX.
 */
@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    /**
     * 添加声明式事务注解
     */
    @Transactional(rollbackFor = {Exception.class, Error.class})
    public void transfer(Double money) {
        userDao.plus(money, "foo");
        userDao.minus(money, "bar");
    }
}
